FROM python:3.13-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV UV_LINK_MODE=copy

# 安装系统依赖
RUN apt-get update && apt-get install -y gcc libpq-dev curl \
    && rm -rf /var/lib/apt/lists/*

# 安装 pip 和 uv
RUN pip install --upgrade pip uv gunicorn

WORKDIR /app

# 复制依赖文件
COPY pyproject.toml .
COPY uv.lock .

# 安装 Python 依赖
RUN uv pip install --system --no-cache .

COPY src .

EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000",  "-w", "4", "app:app"]
